package com.scyshkj.university.wechat.wanxiao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 唐旭 on 2016/11/18.
 */
@Service
public class WanxiaoLoginServiceImpl implements WanxiaoLoginService {

    @Autowired
    private WanxiaoAccessTokenRepository repository;

    @Override
    public String login(String code) {
        WanxiaoAccessToken accessToken = repository.getAvailableToken(code);
//        String userBase = wanxiaoProperties.getUserBase();
//        WanxiaoUserInfo body = restTemplate.getForEntity(userBase + "?" + accessToken.getAccessToken()
//                , WanxiaoUserInfo.class).getBody();
//        if (body != null) {
//            SessionUtils.setAttribute(SessionKeys.WANXIAO_KEY, body);
//            return null;
//        }
        if (accessToken != null) {
            return null;
        }
        return "error";
    }
}
